﻿using System;

namespace OS.Common.Extention.Volidate
{
    /// <inheritdoc />
    /// <summary>
    /// 基础有效性校验基类
    /// </summary>
    [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
    public abstract class BaseValidateAttribute : Attribute
    {
        protected string errorMessage;

        /// <summary>
        /// 错误信息
        /// </summary>
        public string ErrorMessage => this.errorMessage;

        /// <summary>
        /// 有效性校验虚方法
        /// </summary>
        /// <param name="propertyName">属性名称</param>
        /// <param name="propertyValue">属性值</param>
        /// <returns><c>true</c><value>校验正确</value><c>false</c><value>校验失败</value></returns>
        internal abstract bool Validate(string propertyName, object propertyValue);
    }
}